﻿using BaiTu.IOCServices;
using BaiTu.IQueueService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace BaiTu.QueueService.Pub
{
    class Program
    {
        static void Main(string[] args)
        {
            IOCServices.EngineContext.Initialize(false);
            IQueue queue = EngineContext.Current.Resolve<IQueue>();
            ///检查队列是否存在
            queue.CreateIfNotExists<Domains.AppExceptionEntity>();
            Console.WriteLine("开始发送");
            for (var i = 0; i <= 5000; i++)
            {
                Domains.AppExceptionEntity dd = new Domains.AppExceptionEntity()
                {
                    CreateTime = DateTime.Now,
                    ID = i.ToString(),
                    Message = i.ToString() + "this is good"
                };
                string msssID = queue.SendRequestToWorker<Domains.AppExceptionEntity>(dd, "55555");

                var ddd = new Framework.Exceptions.BaiTuSerializedException()
                {
                    Message = i.ToString() +new Exception("不能被0处").ToString()
                };
                msssID = queue.SendRequestToWorker<Framework.Exceptions.BaiTuSerializedException>(ddd);


                Console.WriteLine("发送一条数据");

            }
            Console.Read();
        }
    }
}
